package com.douxg.fastCoding.spring.base;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Map;

/**
 * @Description
 * @Auther douxg
 * @Date 2021/6/4 14:39
 */
public class MyBaseServiceImpl<M extends MyBaseMapper<T>, T extends MyBaseEntity> extends ServiceImpl<M, T> implements MyBaseService<T> {
    @Override
    public IPage<T> mySelectPage(T entity) {
        Page<T> page = new Page<>();
        page.setCurrent(entity.getPageIndex());
        page.setSize(entity.getPageSize());
        return this.baseMapper.selectPage(page, new QueryWrapper<>(entity));
    }

    @Override
    public IPage<Map<String, Object>> mySelectMapsPage(T entity) {
        Page<Map<String, Object>> page = new Page<>();
        page.setCurrent(entity.getPageIndex());
        page.setSize(entity.getPageSize());
        return this.baseMapper.selectMapsPage(page, new QueryWrapper<>(entity));
    }
}
